In [ ]:
%pip install pandas numpy plotly ipykernel
In [ ]:
%pip install -- upgrade ipykernel
Note: you may need to restart the kernel to use updated packages.
ERROR: Could not find a version that satisfies the requirement upgrade (from versions: none) ERROR: No matching distribution found for upgrade [notice] A new release of pip is available: 23.0.1 -> 24.0 [notice] To update, run: C:\Users\Looper\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip
In [ ]:
import pandas as pd
import plotly
import plotly.express as px
import numpy as np
data = pd.read_csv("spotify-2023.csv")
len(data)
data
Out[ ]:
| track_name | artist(s)_name | artist_count | released_year | released_month | released_day | in_spotify_playlists | in_spotify_charts | streams | in_apple_playlists | ... | bpm | key | mode | danceability_% | valence_% | energy_% | acousticness_% | instrumentalness_% | liveness_% | speechiness_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Seven (feat. Latto) (Explicit Ver.) | Latto, Jung Kook | 2 | 2023 | 7 | 14 | 553 | 147 | 141381703 | 43 | ... | 125 | B | Major | 80 | 89 | 83 | 31 | 0 | 8 | 4 |
| 1 | LALA | Myke Towers | 1 | 2023 | 3 | 23 | 1474 | 48 | 133716286 | 48 | ... | 92 | C# | Major | 71 | 61 | 74 | 7 | 0 | 10 | 4 |
| 2 | vampire | Olivia Rodrigo | 1 | 2023 | 6 | 30 | 1397 | 113 | 140003974 | 94 | ... | 138 | F | Major | 51 | 32 | 53 | 17 | 0 | 31 | 6 |
| 3 | Cruel Summer | Taylor Swift | 1 | 2019 | 8 | 23 | 7858 | 100 | 800840817 | 116 | ... | 170 | A | Major | 55 | 58 | 72 | 11 | 0 | 11 | 15 |
| 4 | WHERE SHE GOES | Bad Bunny | 1 | 2023 | 5 | 18 | 3133 | 50 | 303236322 | 84 | ... | 144 | A | Minor | 65 | 23 | 80 | 14 | 63 | 11 | 6 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 948 | My Mind & Me | Selena Gomez | 1 | 2022 | 11 | 3 | 953 | 0 | 91473363 | 61 | ... | 144 | A | Major | 60 | 24 | 39 | 57 | 0 | 8 | 3 |
| 949 | Bigger Than The Whole Sky | Taylor Swift | 1 | 2022 | 10 | 21 | 1180 | 0 | 121871870 | 4 | ... | 166 | F# | Major | 42 | 7 | 24 | 83 | 1 | 12 | 6 |
| 950 | A Veces (feat. Feid) | Feid, Paulo Londra | 2 | 2022 | 11 | 3 | 573 | 0 | 73513683 | 2 | ... | 92 | C# | Major | 80 | 81 | 67 | 4 | 0 | 8 | 6 |
| 951 | En La De Ella | Feid, Sech, Jhayco | 3 | 2022 | 10 | 20 | 1320 | 0 | 133895612 | 29 | ... | 97 | C# | Major | 82 | 67 | 77 | 8 | 0 | 12 | 5 |
| 952 | Alone | Burna Boy | 1 | 2022 | 11 | 4 | 782 | 2 | 96007391 | 27 | ... | 90 | E | Minor | 61 | 32 | 67 | 15 | 0 | 11 | 5 |
953 rows × 24 columns
In [ ]:
realasted_year_group =data.groupby("released_year")
max_streams =realasted_year_group["streams"].idxmax()
new_data=data.loc[max_streams]
px.bar(new_data , x="released_year" , y="streams").show(renderer="notebook")
In [ ]:
data[data['artist(s)_name'].str.contains("Weekend")]
data[data['track_name'].str.contains("Out of Time")]
Out[ ]:
| track_name | artist(s)_name | artist_count | released_year | released_month | released_day | in_spotify_playlists | in_spotify_charts | streams | in_apple_playlists | ... | bpm | key | mode | danceability_% | valence_% | energy_% | acousticness_% | instrumentalness_% | liveness_% | speechiness_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 504 | Out of Time | The Weeknd | 1 | 2022 | 1 | 7 | 3711 | 0 | 339659802 | 49 | ... | 93 | NaN | Minor | 65 | 82 | 74 | 27 | 0 | 32 | 5 |
1 rows × 24 columns
In [ ]:
data["fire"] = data["energy_%"]-data['acousticness_%']+data['valence_%']
fire_limit = np.median(data['fire'])
fire_limit
data["size"] = np.maximum(data["fire"],6)
px.scatter(data, x="streams" , y="fire" , hover_data=["track_name","artist(s)_name","fire"]
,title="itsgob", color="fire", color_continuous_scale=["red", "blue"] ,size="size").show(renderer="notebook")